package com.aaa.service.ImpI;

import com.aaa.dao.TukuMapper;
import com.aaa.entity.MyPage;
import com.aaa.entity.Tuku;
import com.aaa.service.TukuService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
@Service
public class TukuServiceImpI implements TukuService {
    @Autowired
    private TukuMapper tukuMapper;

    @Override
    public PageInfo queryAll(MyPage myPage ,Tuku tuku) {
        PageHelper.startPage(myPage.getPage(),myPage.getLimit());

        PageInfo pageInfo = new PageInfo(tukuMapper.queryAll(tuku));
        return pageInfo;
    }

    @Override
    public boolean addUser(Tuku tuku) {
        int insert=-1;
        String timu=tuku.getTimu();
        String daan1=tuku.getDaan1();
        String daan2=tuku.getDaan2();
        String daan3=tuku.getDaan3();
        String daan4=tuku.getDaan4();
        tuku.setTimu(timu);
        tuku.setDaan1(daan1);
        tuku.setDaan2(daan2);
        tuku.setDaan3(daan3);
        tuku.setDaan4(daan4);
        insert=tukuMapper.insert(tuku);

        return insert>=0?true:false;
    }

    @Override
    public boolean update(Tuku tuku) {
        Integer update = tukuMapper.update(tuku);
        if (update == 0){
            return false;
        }
        return true;
    }





}
